package string;

/**
 * String substring(int start,int end):
 * 截取当前字符串中指定范围中的字符串(含头不含尾)
 */
public class SubstringDemo {
    public static void main(String[] args) {
        String str = "www.tedu.cn";
        int start = 4;
        int end = 8;
        String name = str.substring(start,end);
        System.out.println(name);

        String str1 = "www.baidu.com";
        int start1 = (str1.indexOf(".")+1);
        int end1 = str1.lastIndexOf(".");//int end1 = str1.indexOf(".",start);
        String name1 = str1.substring(start1,end1);
        System.out.println(name1);
    }
}
